
    $(function(){
        //alert(location.href.split('#')[0]);
        var conf="";
        var urld=window.location.href.split('#')[0];
        /*var n1=urld.lastIndexOf("/")+1;
        var men=urld.substring(0,n1);
        var fen=men+"index.html";*/
        //console.log(fen);
        //var urld="www.efguc.com";
        $.ajax({
            type: "post",
            dataType: 'json',
            url: "https://test.efguc.com/saas2.0/api/wx",
            data:{
              url:urld
            },
            success: function(conf) {
                //console.log(conf);
                configWxAPI(conf);
                 var conf=conf.url;
                    return conf;
            },
            error:function(event, XMLHttpRequest, ajaxOptions, thrownError){
                console.log(event);
                console.log(XMLHttpRequest);
                console.log(ajaxOptions);
                console.log(thrownError);
            }
        });
//配置权限
function configWxAPI(conf){
    wx.config({
        debug:false,//开启调试模式，调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端
                    //打开，参数信息会通过log打出，仅在pc端时才会打印
        appId:"wxa9227a372938e0dd",//必填，公众号的唯一标识
        timestamp:conf.timestamp,//必填，生成签名的时间戳
        nonceStr:conf.nonceStr,//必填，生成签名的随机串
        signature:conf.signature,//必填，签名
        jsApiList:[
            'checkJsApi',
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'hideMenuItems',
            'showMenuItems',
            'hideAllNonBaseMenuItem',
            'showAllNonBaseMenuItem',
            'onRecordEnd',
            'openLocation',
            'getLocation',
            'hideOptionMenu',
            'showOptionMenu',
            'chooseImage',
            'uploadImage',
            'previewImage',
            'closeWindow',
            'scanQRCode',
            'chooseWXPay'
        ]//必填，需要使用的JS接口列表，也就是配置你想使用的调用接口
    });
    wx.ready(function(){
        var img="http://tvax3.sinaimg.cn/crop.0.0.800.800.180/006wtuSsly8feqmcbuto4j30m80m8q3d.jpg";
        var urld=window.location.href.split('#')[0];
        //console.log(img);
        //document.title = '邀请好友，拿邀请码';
        //var linelink="https://test.efguc.com/saas2.0/api/html/weixin/index.html";
        var descContent="最轻便的微电台";
        wx.onMenuShareAppMessage( {
            title: "邀请好友",
            desc: "最轻便的微电台",
            link:urld,
            imgUrl:"http://tvax3.sinaimg.cn/crop.0.0.800.800.180/006wtuSsly8feqmcbuto4j30m80m8q3d.jpg",
            success: function () {
                /!*alert('已分享');*!/
                uuid();
                $(".lottery_code").text(uuid());
                window.location.href="user.html";

            },
            cancel: function () {
                alert('已取消');
            }
        });
        wx.onMenuShareTimeline( {
            title: "邀请好友",
            desc: "最轻便的微电台",
            link:urld,
            imgUrl:"http://tvax3.sinaimg.cn/crop.0.0.800.800.180/006wtuSsly8feqmcbuto4j30m80m8q3d.jpg",
            success: function () {
                uuid();
                $(".lottery_code").text(uuid());
                window.location.href="user.html";

            },
            cancel: function () {
                alert('已取消');
            }
        });
    });
    wx.error(function(res){
        console.log(res);
        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
    });
};

        function uuid() {
            var s = [];
            var hexDigits = "0123456789abcdef";
            for (var i = 0; i <4; i++) {
                s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
            }
            s[14] = "3"; // bits 12-15 of the time_hi_and_version field to 0010
            s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
            s[8] = s[13] = s[18] = s[23];
            var uuid = s.join("");
            return uuid;
        };

    });





